//
//  ZDBAlwaysTaskVC.m
//  ZDB
//
//  Created by Kk on 2020/3/20.
//  Copyright © 2020 ZDB. All rights reserved.
//

#import "ZDBAlwaysTaskVC.h"

@interface ZDBAlwaysTaskVC ()
@property(nonatomic,strong)NSDictionary * infoDicc;
@end

@implementation ZDBAlwaysTaskVC
- (void)viewWillAppear:(BOOL)animated
{
     [self statusBarStyleIsDark:NO];
     [self SetnavigationBarBackgroundImage:RGBA(255, 79, 42, 1) Alpha:1];
     [self SetNavigationBarTitleColor:[UIColor whiteColor]];
    
}
- (void)viewWillDisappear:(BOOL)animated
{
    [self statusBarStyleIsDark:YES];
    [self SetNavigationBarTitleColor:MAINTITLECOLOR];
    [self SetnavigationBarBackgroundImage:WHITECOLOR Alpha:1];
    [super viewWillDisappear:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    KViewRadius(_oneLab, 15);
    KViewRadius(_twoLab, 15);
    KViewRadius(_threeLab, 15);
    KViewRadius(_bgView1, 4);
    KViewRadius(_bgView2, 4);
    KViewRadius(_bgView3, 4);
    self.navigationItem.title = @"永久任务";
    [self initBackButton:YES];
    _tableView.backgroundColor = RGBA(255, 79, 42, 1);
    _tableView.showsVerticalScrollIndicator = NO;
    _tableView.alwaysBounceVertical = NO;
    [self refushData];
    [self getShareMoney];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
-(void)refushData{
    
    //getUserShareInfo
    NSString  * inurl = [[YINetWorkAPIGenerate sharedInstance] APINomark:@"getUserShareInfo"];
    WEAKSELF
    [[SmileHttpTool sharedInstance] POST :inurl parameters:nil origin:NO success:^(NSInteger statusCode, NSString *message, id responseObject) {
      STRONGSELFFor(weakSelf)
        
        if (statusCode==0) {
        NSLog(@"userGoods_getUserGoodsList----%@",responseObject);
            NSDictionary * datadicc = [NSDictionary dictionaryWithDictionary:responseObject];
            strongSelf.infoDicc = datadicc;
            dispatch_async(dispatch_get_main_queue(), ^{
                [strongSelf changeUiData];
            });
            
        }else{
             [JMNotifyView showNotify:message isSuccessful:NO];
        }
          
        // [strongSelf stopLoadingAnimation];
  
    } failure:^(id responseObject, NSError *error) {
        NSLog(@"error----%@",error);
       //  STRONGSELFFor(weakSelf)
        
        [JMNotifyView showNotify:@"网络错误，请重试~" isSuccessful:NO];
        // [self stopLoadingAnimation];
    }];
    
}
- (void)getShareMoney
{
    //getUserShareInfo
      NSString  * shareMoney = [[YINetWorkAPIGenerate sharedInstance] APINomark:@"shareMoney"];
      WEAKSELF
      [[SmileHttpTool sharedInstance] POST :shareMoney parameters:nil origin:NO success:^(NSInteger statusCode, NSString *message, id responseObject) {
        STRONGSELFFor(weakSelf)
          
          if (statusCode==0) {
         
              NSString * string = kFormat(@"1.用户注册掌兑宝，并且完成资质认证;\n2.通过邀请链接邀请好友注册掌兑宝，完成资质认证并且完成一次任务为一个有效邀请;\n3.每个有效邀请，将会获得%@元的奖励，奖励在被邀请用户完成任务时自动发放；\n4.禁止刷单或者其他作弊行为，请勿使用刷单工具和其他第三方刷单平台，否则损失后果自负。 本活动解释权在法律范围内归本公司所有。", responseObject[@"value"]);
                weakSelf.contentLab.attributedText = [ZBDUnit finderattributedLinesString:string attributedString:string color:MAINTITLECOLOR font:AutoFont(14)];
                 
              
          }else{
               [JMNotifyView showNotify:message isSuccessful:NO];
          }
            
          // [strongSelf stopLoadingAnimation];
    
      } failure:^(id responseObject, NSError *error) {
          NSLog(@"error----%@",error);
         //  STRONGSELFFor(weakSelf)
          
          [JMNotifyView showNotify:@"网络错误，请重试~" isSuccessful:NO];
          // [self stopLoadingAnimation];
      }];
}
-(void)changeUiData{
    
    self.priceValue.text = [NSString stringWithFormat:@"¥%@元",[self.infoDicc jsonString:@"shareMoney"]];
    self.numValue.text = [NSString stringWithFormat:@"%@人",[self.infoDicc jsonString:@"shareCount"]];
    
//    收益=1级返利20%
//        +2级返利15%
//        +3级返利10%
//      +4级返利5%

  
    
    
}
- (IBAction)classBtn:(UIButton *)sender {
    
    if (![ZBDUnit getLoginJurisdiction]) {
        return;
    }
    switch (sender.tag) {
        case 0://分享
        {
            [[ZDBAlertHelper sharedInstance] alert_PopEShareWith:self.infoDicc isNmuberShoare:YES isInvitationShoare:NO andActionBlock:^(NSInteger actionType) {
            }];
        }
            break;
        case 1://邀请
        {
            [[ZDBAlertHelper sharedInstance] alert_PopEShareWith:self.infoDicc isNmuberShoare:NO isInvitationShoare:NO andActionBlock:^(NSInteger actionType) {
            }];
        }
            break;
        case 2://复制
        {
            [JMNotifyView showNotify:@"邀请链接已复制到粘贴板" isSuccessful:YES];
            UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
            pastboard.string = [self.infoDicc jsonString:@"shareUrl"];
            
        }
            break;
        default:
            break;
    }
}
@end
